declare var require: any
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path, { resolve } from 'path'
import stylePxToVw from "./stylePxToVw";
import pxtoviewport from "postcss-px-to-viewport";
const pathResolve = (dir: string): any => {
  return resolve(__dirname, '.', dir)
}
export default defineConfig({
  plugins: [vue(),stylePxToVw()],
  define: {
    'process.env': {},
  },
  base:'./',
  server: {
    port: 8080,
    hmr: true
  },
  resolve: {
    alias: {
      '@': pathResolve('./src/')
    }
  },
  css: {
    preprocessorOptions: {
      javascriptEnabled: true,
      less: {
        javascriptEnabled: true,
      },
      
    },
    postcss: {
      plugins: [
        pxtoviewport({
          unitToConvert: "px",
          viewportWidth: 1920,
          unitPrecision: 5,
          propList: ["*"],
          viewportUnit: "vw",
          fontViewportUnit: "vw",
          selectorBlackList: [],
          minPixelValue: 1,
          mediaQuery: false,
          replace: true,
          exclude: [],
          landscape: false,
          landscapeUnit: "vw",
          landscapeWidth: 1280,
        }),
      ],
    },
  },
})
